package com.example.pc.adapterdemo.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.example.pc.adapterdemo.MainActivity;
import com.example.pc.adapterdemo.R;

public class ItemActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {

    private ListView mListView;
    private String[] strs = {"屏幕适配", "通用adapter", "自定义标题栏", "全屏沉浸式", "TabLayout", "WheelView", "Loading"};
    private ArrayAdapter<String> adapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.item_layout);

        initView();
    }

    private void initView() {
        mListView = findViewById(R.id.mListView);
        adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, strs);
        mListView.setAdapter(adapter);

        mListView.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        switch (i) {
            case 0:
                startActivity(new Intent(ItemActivity.this, ScreenActivity.class));
                break;

            case 1:
                startActivity(new Intent(ItemActivity.this, MainActivity.class));
                break;

            case 2:
                startActivity(new Intent(ItemActivity.this, CreateViewActivity.class));
                break;

            case 3:
                startActivity(new Intent(ItemActivity.this, ActionBarActivity.class));
                break;

            case 4:
                startActivity(new Intent(ItemActivity.this, TabLayoutActivity.class));
                break;

            case 5:
                startActivity(new Intent(ItemActivity.this, WheelViewActivity.class));
                break;

            case 6:
                startActivity(new Intent(ItemActivity.this, LoadingActivity.class));
                break;
        }
    }
}
